/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



package sonia.golf;

//~--- non-JDK imports --------------------------------------------------------

import android.app.TabActivity;

import android.content.Intent;
import android.content.res.Resources;

import android.os.Bundle;

import android.widget.TabHost;

import sonia.golf.dao.DAOFactory;

/**
 *
 * @author Sebastian Sdorra
 */
public class TabWidget extends TabActivity
{

  /**
   * Method description
   *
   *
   * @param savedInstanceState
   */
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    DAOFactory.getInstance().init(this);
    setContentView(R.layout.mainlayout);

    Resources res = getResources();
    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(this, PlayerActivity.class);

    // TODO Add icon
    spec = tabHost.newTabSpec("players").setIndicator(
      res.getString(R.string.players)).setContent(intent);
    tabHost.addTab(spec);
    intent = new Intent().setClass(this, CourseActivity.class);
    spec = tabHost.newTabSpec("courses").setIndicator(
      res.getString(R.string.courses)).setContent(intent);
    tabHost.addTab(spec);
    tabHost.setCurrentTab(0);
  }

  /**
   * Method description
   *
   */
  @Override
  protected void onDestroy()
  {
    super.onDestroy();
    DAOFactory.getInstance().close(this);
  }
}
